home *** CD-ROM | disk | FTP | other *** search
- #include <Palettes.h>
- #include <GestaltEqu.h>
- #include <Icons.h>
- #include <A4Stuff.h>
- #include "DS Additions.h"
- #include "Drag.h"
-
- #define ScreenDepth(gdh) ((*((*gdh)->gdPMap))->pixelSize)
-
- pascal long main( DSAdditionParamBlockPtr params)
- {
- long result = 0;
- Rect localRect;
- Point mousePoint;
- OSErr theErr;
- RGBColor redColor, blueColor;
- long oldA4 = SetCurrentA4();
-
- switch(params->dsMessage) {
- /////////
- // Given a draw message, draw what we need into the
- // provided rectangle
- /////////
- case kMsgInitAddition:
- params->dsRefCon = (long)NewHandle(10); //Allocate some memory for some reason
- result = MemError();
- break;
-
- case kMsgCloseAddition:
- if(params->dsRefCon != nil) {
- DisposeHandle((Handle)params->dsRefCon);
- }
- break;
-
- case kMsgDraw:
- localRect = params->dsTextRect;
-
- redColor.red = 0xffff;
- redColor.green = 0x0000;
- redColor.blue = 0x0000;
- RGBForeColor(&redColor);
-
- if((localRect.right - localRect.left) >= 20) {
- TextFont(applFont);
- TextFace(0);
- TextSize(9);
- TextBox("Hello", 5, &localRect , teCenter);
- }
- params->dsNextDrawTime = TickCount() + 300; //Draw again in 5 seconds
- break;
-
- /////////
- // Given a draw hilite message, draw what we need into
- // the provided rectangle
- /////////
- case kMsgDrawHilite:
- localRect = params->dsTextRect;
-
- blueColor.red = 0x0000;
- blueColor.green = 0x0000;
- blueColor.blue = 0xffff;
- RGBForeColor(&blueColor);
-
- if((localRect.right - localRect.left) >= 20) {
- TextFont(applFont);
- TextFace(0);
- TextSize(9);
-
- TextBox("World", 5, &localRect , teCenter);
- }
- break;
-
-
- params->dsNextDrawTime = TickCount() + 300; //Draw again in 5 seconds
-
- /////////
- // Given a hit message, do whatever we do when we are hit
- /////////
- case kMsgHit:
- localRect = params->dsLocalRect;
- GetMouse(&mousePoint);
-
- //Make sure that the user actually let go inside the rect
- //before doing our thing.
- while(StillDown() && PtInRect(mousePoint, &localRect)) {
- GetMouse(&mousePoint);
- }
-
- if(!StillDown()) {
- SysBeep(10);
- }
- break;
-
- /////////
- // Given a drop message, pull the files out of the
- // DragReference then do what you want with them.
- /////////
- case kMsgDropOccurred:
- {
- unsigned short items, index;
-
- CountDragItems(params->dsDragReference, &items);
- for (index = 1; index <= items; index++) {
- SysBeep(10);
- }
- }
- break;
-
-
- }
-
- SetA4(oldA4);
- return result;
- }
-